<!DOCTYPE html>
<html>
<head th:include="cultivateWeb/header :: culHeaderCss">
</head>
<link type="text/css" href="/css/cultivateWeb/style/news.css" rel="stylesheet">
<body>
<!-- 顶部导航 -->
<header th:include="cultivateWeb/header :: header"></header>
<div style="background-color: #f7f7f7; ">
    <div class="layui-container">
        <p style="line-height: 40px">当前位置：<a href="/cultivate/homepage">首页</a> > 行业公告</p>
        <input type="hidden" id="name" th:value="${name}"/>
    </div>
    <div style="width: 1200px; margin: auto">
        <span class="title gg" id="hySpan">行业信息</span>
        <span class="title1 gg" id="ggSpan">公告板</span>
    </div>
    <hr style="margin: auto auto 40px auto  ; width: 1200px"/>

    <!-- 行业信息 -->
    <section id="info" style="background-color: #f7f7f7;padding: 0 ">
        <div class="div1">
            <a href="#"><span class="news zx" b="0">行业信息</span></a>
            <a href="#"><span class="sp zx" b="1">政策信息</span></a>
            <a href="#"><span class="sp zx" b="2">标准信息</span></a>
            <!--<a href="#"><span id="jgxx" class="sp zx" b="3">机构介绍</span></a>-->
        </div>
        <!--行业资讯-->
        <div id="hy" class="xx">
            <div id="content" style="background-color: #f7f7f7; width: 1200px; margin: 0 auto"></div>
            <div id="page" class="page"></div>
        </div>

        <div id="zs" class="xx" style="display: none">
            <div id="content1" style="background-color: #f7f7f7; width: 1200px; margin: 0 auto">

            </div>
            <div id="page2" class="page"></div>
        </div>
    </section>



    <!-- 公告板 -->
    <section id="notice" style="display: none;padding: 0 ">
        <div class="div1">
            <!--<span class="news ggb zx" b="4">培训公告</span>-->
            <span class="sp ggb zx news" b="5">通知公告</span>
        </div>
        <div class="xx">
            <div id="content4" style="background-color: #f7f7f7; width: 1200px; margin: 0 auto"></div>
            <div id="page4" class="page"></div>
        </div>
    </section>
</div>
<!-- footer ------------------------------------------------------- -->
<div class="footer" th:include="cultivateWeb/header :: footer"></div>
<script type="text/javascript" src="/js/xlPaging.js"></script>
</body>

<script>
    $(function () {
        var name =$("#name").val();
        getData(name);
        if(name=='通知公告'){
            $("#info").css("display","none");
            $("#notice").css("display","inline");

        }else{
            $("#info").css("display","inline");
            $("#notice").css("display","none");
        }
        $(".gg").each(function () {
            if(name=='通知公告'){
                if($(this).text()=='公告板'){
                    $(this).addClass("title");
                    $(this).siblings().removeClass("title");
                    $(this).siblings().addClass("title1");
                }
            }else{
                if($(this).text()=='行业信息'){
                    $(this).addClass("title");
                    $(this).siblings().removeClass("title");
                    $(this).siblings().addClass("title1");
                }
            }
        });
        //一级切换
        $('.gg').click(function () {
            //行业信息
            if ($(this).text() == '行业信息'){
                $("#info").css("display","inline");
                $("#notice").css("display","none");
            }
            //公告板
            if ($(this).text() == '公告板'){
                getData("通知公告");
                $("#info").css("display","none");
                $("#notice").css("display","inline");
            }
            $(this).addClass("title");
            $(this).siblings().removeClass("title");
            $(this).siblings().addClass("title1");
        });
        //二级切换
        $('.zx').click(function () {
            $(this).addClass("news");
            $(this).parent("a").siblings().find("span").removeClass("news");
            $(this).parent("a").siblings().find("span").addClass("sp");
            if ($(this).attr("b") == 2){
                $("#hy").css("display","none");
                $("#xx").css("display","none");
                $("#zs").css("display", "block");

                getZsData()
            }else {
                getData($(this).text());
                $("#zs").css("display", "none");
                $("#hy").css("display","block");
                $("#xx").css("display","block");
            }
            getData($(this).text());
        })


    });
    function getData(name){
        var url='';
        if(name=='标准信息'){
            url="/certificate/selCertificateInfo"
        }else{
            url="/jzApi/index/selNewsList"
        }
        $.ajax({
            url:url ,
            type: 'GET',
            data: {
                firstColumn:'培训就业门户',
                columnName:name,
                current: 1,
                number:8
            },
            success: function (res) {
                if(res.data.pages==0){
                    if(name=='通知公告'){
                        $("#content4").html('<div class="noData">暂无数据</div>');
                    }else{
                        $("#content").html('<div class="noData">暂无数据</div>');
                    }
                }else{
                    var list = res.data.records;
                    var news = '';
                    if(name=='标准信息'){
                        list.forEach(function (item, index) {
                            var a ='';
                            if(item.grade==0){
                                a='(高级)'
                            }else if(item.grade==1){
                                a='(中级)'
                            }else if(item.grade==2){
                                a='(初级)'
                            }
                            news += ' <div class="div_00">' +
                                '<div class="title_3">' + item.profileName + a + '</div>' +
                                '<div class="span_1 b18"><span class="title_1">证书介绍：</span><p class="title_2">' + item.introduce + '</p></div>' +
                                '<div class="span_1 b18"><span class="title_1">相关专业：</span><p class="title_2">' + item.relatedMajors + '</p></div>' +
                                // '<div class="span_1 b18"><span class="title_1">考试总费用：</span><p class="title_2">' + item.examFee + '元</p></div>' +
                                '</div>';
                        });
                    }else{
                        list.forEach(function (item, index) {
                            var a ='';
                            if(item.thumbnail!='' && item.thumbnail!=null){
                                a='<img style="width: 180px;height: 110px" src="'+item.thumbnail+'" />'
                            }else{
                                a='<div class="bg_green">'+name+'</div>'
                            }
                            if(item.title.length>38){
                                item.title = item.title.substring(0, 38) + '...'
                            }
                            news += '<a href="/notice/newsInfo?name='+name+'&'+'id='+item.id+'">' +
                                '<div class="div2">' +
                                '<div style="float: left">'+a+'</div>' +
                                '<div style="float: left;width: 370px;"><p class="p1">'+item.title+'</p>'
                                +'<p class="p2">'+item.createrDate+'</p>' +
                                '</div><div style="clear: both"></div></a></div>';
                        });
                        news +='<div style="clear: both"></div>';
                    }

                    if(name=='通知公告'){
                        $("#content4").html(news);
                    }else{
                        $("#content").html(news);
                    }
                    page(1,res.data.pages,name);
                }
            }
        })
    }
    function page(num,tolPages,name) {
        var a='';
        if(name=='通知公告'){
            a='page4';
        }else{
            a='page';
        }
        var url='';
        if(name=='标准信息'){
            url="/certificate/selCertificateInfo"
        }else{
            url="/jzApi/index/selNewsList"
        }

        $("#"+a).paging({
            nowPage:Number(num), // 当前页码
            pageNum:Number(tolPages), // 总页码
            buttonNum:5, //要展示的页码数量
            canJump: 1,// 是否能跳转。0=不显示（默认），1=显示
            showOne: 0,//只有一页时，是否显示。0=不显示,1=显示（默认）
            callback: function (num) { //回调函数
                $.ajax({
                    url: url,
                    type: 'GET',
                    data: {
                        firstColumn:'培训就业门户',
                        columnName: name,
                        current:num,
                        number:8
                    },
                    success:function (res) {
                        var list = res.data.records;
                        var news = '';
                        if(name=='标准信息'){
                            list.forEach(function (item, index) {
                                var a ='';
                                if(item.grade==0){
                                    a='(高级)'
                                }else if(item.grade==1){
                                    a='(中级)'
                                }else if(item.grade==2){
                                    a='(初级)'
                                }
                                news += ' <div class="div_00">' +
                                    '<div class="title_3">' + item.profileName + a + '</div>' +
                                    '<div class="span_1 b18"><span class="title_1">证书介绍：</span><p class="title_2">' + item.introduce + '</p></div>' +
                                    '<div class="span_1 b18"><span class="title_1">相关专业：</span><p class="title_2">' + item.relatedMajors + '</p></div>' +
                                    // '<div class="span_1 b18"><span class="title_1">考试总费用：</span><p class="title_2">' + item.examFee + '元</p></div>' +
                                    '</div>';
                            });
                        }else{
                            list.forEach(function (item, index) {
                                var a ='';
                                if(item.thumbnail!='' && item.thumbnail!=null){
                                    a='<img style="width: 180px;height: 110px" src="'+item.thumbnail+'" />'
                                }else{
                                    a='<div class="bg_green">'+name+'</div>'
                                }
                                if(item.title.length>38){
                                    item.title = item.title.substring(0, 38) + '...'
                                }
                                news += '<a href="/notice/newsInfo?name='+name+'&'+'id='+item.id+'">' +
                                    '<div class="div2">' +
                                    '<div style="float: left">'+a+'</div>' +
                                    '<div style="float: left;width: 370px;"><p class="p1">'+item.title+'</p>'
                                    +'<p class="p2">'+item.createrDate+'</p>' +
                                    '</div><div style="clear: both"></div></a></div>';
                            });
                            news +='<div style="clear: both"></div>';
                        }

                        if(name=='通知公告'){
                            $("#content4").html(news);
                        }else{
                            $("#content").html(news);
                        }
                    }
                });
            }
        });
    }

    function getZsData() {
        $.ajax({
            url: "/certificate/selCertificateInfo",
            type: 'GET',
            data: {
                current: 1,
                number: 8
            },
            success: function (res) {
                if (res.data.pages == 0) {
                    $("#news").html('<div class="noData">暂无数据</div>');
                } else {
                    var list = res.data.records;
                    var news = '';
                    list.forEach(function (item, index) {
                        var a ='';
                        if(item.grade==0){
                            a='(高级)'
                        }else if(item.grade==1){
                            a='(中级)'
                        }else if(item.grade==2){
                            a='(初级)'
                        }
                        news += '<div class="bz">' +
                            '<span class="mc_1">'+item.profileName+a+'</span><br/>' +
                            '<span class="js">证书介绍：</span><span class="js_con">'+item.introduce+'</span><br/>' +
                            '<span class="js">相关专业：</span></span><span class="js_con">'+item.relatedMajors+'</span>' +
                            '</div>' +
                            '<hr/>';
                    });
                    news +='<div style="clear: both"></div>';
                    $("#content1").html(news);
                    page2(1,res.data.pages);
                }
            }
        })
    }

    function page2(num,tolPages) {

        $("#page2").paging({
            nowPage: Number(num), // 当前页码
            pageNum: Number(tolPages), // 总页码
            buttonNum: 3, //要展示的页码数量
            canJump: 1,// 是否能跳转。0=不显示（默认），1=显示
            showOne: 1,//只有一页时，是否显示。0=不显示,1=显示（默认）
            callback: function (num) { //回调函数
                $.ajax({
                    url: "/certificate/selCertificateInfo",
                    type: 'GET',
                    data: {
                        current: num,
                        number: 8
                    },
                    success: function (res) {
                        if (res.data.pages == 0) {
                            $("#news").html('<div class="noData">暂无数据</div>');

                        } else {
                            var list = res.data.records;
                            var news = '';
                            list.forEach(function (item, index) {
                                var a = '';
                                if (item.grade == 0) {
                                    a = '(高级)'
                                } else if (item.grade == 1) {
                                    a = '(中级)'
                                } else if (item.grade == 2) {
                                    a = '(初级)'
                                }
                                news += '<div class="bz">' +
                                    '<span class="mc_1">' + item.profileName + a + '</span><br/>' +
                                    '<span class="js">证书介绍：</span><span class="js_con">' + item.introduce + '</span><br/>' +
                                    '<span class="js">相关专业：</span></span><span class="js_con">' + item.relatedMajors + '</span>' +
                                    '</div>' +
                                    '<hr/>';
                            });
                            news += '<div style="clear: both"></div>';
                            $("#content1").html(news);
                        }
                    }
                });
            }
        })
    }

</script>
</html>